package com.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.entity.Account;
import com.example.mapper.AccountMapper;
import com.example.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author latin-xiao-mao
 * @date 2020/7/8 21:02
 * @description
 * @className AccountServiceImpl
 */
@Service // 通过该注解就可以注入到 spring 的 IOC 中
public class AccountServiceImpl implements AccountService {

	@Autowired
	private AccountMapper accountMapper;

	@Override
	public Account findByUsername(String username) {

		// 构造 mybatis-plus 的查询体
		QueryWrapper queryWrapper = new QueryWrapper();
		queryWrapper.eq("username", username); // 来查找 username 对象的值是否等于你给定的参数 username

		return accountMapper.selectOne(queryWrapper);
	}
}
